<template>
  <div class="header-box">
    <div class="info">
      <img :src="userInfo.img" alt="">
      <p>{{userInfo.name}}</p>
    </div>
    <el-button class="off-btn" @click="exit">退出</el-button>
  </div>
</template>


<script>
import { mapState } from 'vuex'
export default {
  computed: {
    ...mapState(['userInfo'])
  },
  methods: {
    exit() {
      // 删除本地存储
      localStorage.removeItem('token');

      this.$router.push('/login')
    }
  },
}
</script>
<style lang="scss" scoped>
.header-box {
  height: 64px;
  background: #ffffff;
  box-shadow: 0px 1px 4px 0px rgba(0, 21, 41, 0.12);
  display: flex;
  align-items: center; 
  justify-content: flex-end;
  padding: 0 20px;
}
.info {
  display: flex;
  align-items: center;
  margin-right: 10px;
  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
}
</style>